package com.tianqu.tms.www.car.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAjaxAction;
import com.tianqu.tms.core.base.TxController;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.core.util.StringUtil;
import com.tianqu.tms.entity.Codes;


/** 
 * 道闸信息
 * @author mufeiyu
 */
public class CarImportExportGateInfoAjaxAction extends TmsAjaxAction{
	private Logger logger = Logger.getLogger(CarImportExportGateInfoAjaxAction.class);
	private static final String GATEID = "gateId";
	private static final String ENTRANCETYPE = "entranceType";
	@Override
	public void process(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws TmsException {
		logger.debug(this.getClass().getName() + "#execute was called.");
		TxController controller = TxController.getTxController();
		controller.begin();
		String gateId = request.getParameter(GATEID);
		String entranceType = request.getParameter(ENTRANCETYPE);
		
		String gateIp = "";
		Codes code = Codes.getInstance();
		if(!"0".equals(gateId) && !StringUtil.isNullOrBlank(gateId)){
			gateIp = code.getItemValueByItemIdAndItemCode(Codes.GATEWAY_IP, Integer.valueOf(gateId));
		}
		
		//拼select
		StringBuffer str = new StringBuffer();
		str.append(entranceType);
		str.append("##");
		str.append(gateIp);
		
		String responseText =str.toString();
		controller.commit();
		responseValues(response, responseText, TEXT);
		
		logger.debug(this.getClass().getName() + "#doAction was completed.");
	}

}
